//========================================================================
// *作者：海盗猫  主页：ilplay.com
// *脚本：UIDisplay
// *描述：UI对象的核心数据脚本
// *?2021 MYJL . All rights reserved.
//* ======================================================================
using System.Collections.Generic;
using UnityEngine;

namespace HDMCode.UIFrame
{
    /// <summary>
    /// 组件元素
    /// </summary>
    [System.Serializable]
    public class UIComponentElement
    {
        [SerializeField]
        public GameObject target;

        [SerializeField]
        public List<Component> componentList;
    }

    /// <summary>
    /// UI显示
    /// </summary>
    [DisallowMultipleComponent]
    public class UIDisplay : MonoBehaviour
    {
        /// <summary>
        /// 根据不同平台选择不同的生命周期
        /// </summary>
        private IUIDisplayLife _uiLife;

        public IUIDisplayLife uiLife { get {if (!_uiLife) _uiLife = this.gameObject.GetComponent<IUIDisplayLife>();return _uiLife; }  }

        /// <summary>
        /// UI的脚本类型
        /// </summary>
#if (UNITY_EDITOR)
        public int compilationType = 0;
        public string scriptDescribe;
#endif

        /// <summary>
        /// UI字段组件信息
        /// </summary>
        public object fileds { get; set; }

        /// <summary>
        /// UI名称
        /// </summary>
        public new string name { get => this.gameObject.name; }

        /// <summary>
        /// UI脚本名称
        /// </summary>
        public string uISingleName;

        /// <summary>
        /// UI窗口类型
        /// </summary>
        public WrapperType wrapperType;

        /// <summary>
        /// UI显示方式
        /// </summary>
        public ShowType showType;

        /// <summary>
        /// UI穿透检测
        /// </summary>
        public PierceType pierceType= PierceType.Impenetrate;

        /// <summary>
        /// UI背景颜色
        /// </summary>
        public BackGroundType backGroundType;

        /// <summary>
        /// UI背景颜色
        /// </summary>
        public Color backGroundColor;
        
        /// <summary>
        /// 动画组件
        /// </summary>
        public new RuntimeAnimatorController animation;

        /// <summary>
        /// 开启音频
        /// </summary>
        public AudioClip openAudio;
        
        /// <summary>
        /// 关闭音频
        /// </summary>
        public AudioClip closeAudio;

        /// <summary>
        /// UI关联组件信息
        /// </summary>
        public List<UIComponentElement> components;
    }

}

